# coding:utf-8
from odoo import models, fields, api, _
from odoo.exceptions import Warning


class ZfyQuotationsValidate(models.Model):
    _name = 'sale.order'
    _inherit = 'sale.order'

    @api.model
    def create(self, vals):
        sb = vals.get('order_line')
        if len(sb)==0:
            raise Warning(_(u'请选择订单明细！'))
        return super(ZfyQuotationsValidate, self).create(vals)

    @api.multi
    def write(self, vals):
        a = vals.get('order_line')
        if a is not None:
            flag=0
            for cc in a:
                ff=cc[0]
                if ff==4 or ff==0 or ff==1:
                    flag=1
            if flag==0:
                raise Warning(_(u'请选择订单明细！'))
        return super(ZfyQuotationsValidate, self).write(vals)
